#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define ARRAY_CAP 256

void sort(char *str);
void swap(char *str, int i, int j);

int main(void)
{
    char str[ARRAY_CAP] = {0};
    for(int i = 0; i < ARRAY_CAP; ++i)
        str[i] = rand() % 26 + 'A';

    //Imprimir desordenado
    printf("\n%s\n", str);
    clock_t t0 = clock();
    sort(str);
    clock_t t = clock();

    //Imprimir ordenado
    printf("\n%s\n", str);

    //Imprimir tiempo
    printf("\nTiempo del algoritmo = %ld microseg\n", t - t0);
}

void sort(char *str)
{
    for(int i = 0; str[i]; ++i)
        for(int j = i; str[j]; ++j)
            if(str[i] > str[j])
                swap(str, i, j);
}

void swap(char *str, int i, int j)
{
    char c = str[i];
    str[i] = str[j];
    str[j] = c;
}
